<html>
  <head>
    <meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
    <title>plot</title>
  </head>
  <body bgcolor="#FFFFFF">
    <center>Scilab Function</center>
    <div align="right">Last update : 07/02/2006</div>
    <p>
      <b>plot</b> - 2D plot</p>
    <h3>
      <font color="blue">Calling Sequence</font>
    </h3>
    <dl>
      <dd>
        <tt>plot(y,&lt;LineSpec&gt;,&lt;GlobalProperty&gt;)</tt>
      </dd>
      <dd>
        <tt>plot(x,y,&lt;LineSpec&gt;,&lt;GlobalProperty&gt;)</tt>
      </dd>
      <dd>
        <tt>plot(x1,y1,&lt;LineSpec1&gt;,x2,y2,&lt;LineSpec2&gt;,...xN,yN,&lt;LineSpecN&gt;,&lt;GlobalProperty1&gt;,&lt;GlobalProperty2&gt;,..&lt;GlobalPropertyM&gt;)</tt>
      </dd>
      <dd>
        <tt>plot(&lt;axes_handle&gt;,...)</tt>
      </dd>
    </dl>
    <h3>
      <font color="blue">Parameters</font>
    </h3>
    <ul>
      <li>
        <tt>
          <b>x</b>
        </tt>: a real matrice or vector. If omitted, it is assumed to be the
          vector <tt>
          <b>1:n</b>
        </tt> where <tt>
          <b>n</b>
        </tt> is the number of curve
          points given by the <tt>
          <b>y</b>
        </tt> parameter.</li>
      <li>
        <tt>
          <b>y</b>
        </tt>: a real matrice or vector. <tt>
          <b>y</b>
        </tt> can also be a
          function defined as a macro or a primitive.</li>
      <li>
        <tt>
          <b>&lt;LineSpec&gt;</b>
        </tt>: This optional argument must be a string that will be used as a
          shortcut to specify a way of drawing a line. We can have one
          <tt>
          <b>LineSpec</b>
        </tt> per<tt>
          <b> y</b>
        </tt> or <tt>
          <b>{x,y}</b>
        </tt>
          previously entered. <tt>
          <b>LineSpec</b>
        </tt> options deals with
          LineStyle, Marker and Color specifiers (see <a href="LineSpec.htm">
          <tt>
            <b>LineSpec</b>
          </tt>
        </a>).
          Those specifiers determine the line style, mark style and color of
          the plotted lines.</li>
      <li>
        <tt>
          <b>&lt;GlobalProperty&gt;</b>
        </tt>: This optional argument represents a sequence of couple
          statements <tt>
          <b>{PropertyName,PropertyValue}</b>
        </tt> that defines
          global objects' properties applied to all the curves created by this
          plot. For a complete view of the available properties (see
          <a href="GlobalProperty.htm">
          <tt>
            <b>GlobalProperty</b>
          </tt>
        </a>).</li>
      <li>
        <tt>
          <b>&lt;axes_handle&gt;</b>
        </tt>: This optional argument forces the plot to appear inside the
          selected axes given by <tt>
          <b>axes_handle</b>
        </tt> rather than the
          current axes (see <a href="gca.htm">
          <tt>
            <b>gca</b>
          </tt>
        </a>).</li>
    </ul>
    <h3>
      <font color="blue">Description</font>
    </h3>
    <p>
      <tt>
        <b>plot</b>
      </tt> plots a set of 2D curves. <tt>
        <b>plot</b>
      </tt> has been
    rebuild to better handle Matlab syntax. To improve graphical
    compatibility, Matlab users should use <tt>
        <b>plot</b>
      </tt> (rather than
    <a href="plot2d.htm">
        <tt>
          <b>plot2d</b>
        </tt>
      </a>).</p>
    <p>Data entry specification :</p>
    <p>In this paragraph and to be more clear, we won't mention
    <tt>
        <b>LineSpec</b>
      </tt> nor <tt>
        <b>GlobalProperty</b>
      </tt> optional arguments
    as they do not interfer with entry data (except for <tt>
        <b>"Xdata"</b>
      </tt>,
    <tt>
        <b>"Ydata"</b>
      </tt> and <tt>
        <b>"Zdata"</b>
      </tt> property, see
    <a href="GlobalProperty.htm">
        <tt>
          <b>GlobalProperty</b>
        </tt>
      </a>). It is assumed that all those optional
    arguments could be present too.</p>
    <p>If <tt>
        <b>y</b>
      </tt> is a vector, plot(y) plots vector <tt>
        <b>y</b>
      </tt>
    versus vector <tt>
        <b>1:size(y,'*')</b>
      </tt>.</p>
    <p>If <tt>
        <b>y</b>
      </tt> is a matrix, plot(y) plots each columns of
    <tt>
        <b>y</b>
      </tt> versus vector <tt>
        <b>1:size(y,1)</b>
      </tt>.</p>
    <p>If <tt>
        <b>x</b>
      </tt> and <tt>
        <b>y</b>
      </tt> are vectors, plot(x,y) plots
    vector <tt>
        <b>y</b>
      </tt> versus vector <tt>
        <b>x</b>
      </tt>. <tt>
        <b>x</b>
      </tt> and
    <tt>
        <b>y</b>
      </tt> vectors should have the same number of entries.</p>
    <p>If <tt>
        <b>x</b>
      </tt> is a vector and <tt>
        <b>y</b>
      </tt> a matrix plot(x,y)
    plots each columns of <tt>
        <b>y</b>
      </tt> versus vector <tt>
        <b>x</b>
      </tt>. In this
    case the number of columns of <tt>
        <b>y</b>
      </tt> should be equal to the number
    of <tt>
        <b>x</b>
      </tt> entries.</p>
    <p>If <tt>
        <b>x</b>
      </tt> and <tt>
        <b>y</b>
      </tt> are matrices, plot(x,y) plots each
    columns of <tt>
        <b>y</b>
      </tt> versus corresponding column of <tt>
        <b>x</b>
      </tt>.
    In this case the <tt>
        <b>x</b>
      </tt> and <tt>
        <b>y</b>
      </tt> sizes should be the
    same.</p>
    <p>Finally, if only <tt>
        <b>x</b>
      </tt> or <tt>
        <b>y</b>
      </tt> is a matrix, the
    vector is plotted versus the rows or columns of the matrix. The choice is
    made depending on whether the vector's row or column dimension matches the
    matrix row or column dimension. In case of a square matrix (on
    <tt>
        <b>x</b>
      </tt> or <tt>
        <b>y</b>
      </tt> only), priority is given to columns
    rather than lines (see examples below).</p>
    <p>
      <tt>
        <b>y</b>
      </tt> can also be a function defined as a macro or a
    primitive. In this case, <tt>
        <b>x</b>
      </tt> data must be given (as a vector or
    matrix) and the corresponding computation <tt>
        <b>y(x)</b>
      </tt> is done
    implicitly.</p>
    <p>The <tt>
        <b>LineSpec</b>
      </tt> and <tt>
        <b>GlobalProperty</b>
      </tt> arguments
    sould be used to customize the plot. Here is a complete list of the
    available options.</p>
    <dl>
      <dd>
        <b></b>
      </dd>
    </dl>
    <dl>
      <dd>
        <b>LineSpec</b>: This option may be used to specify, in a short and easy manner,
        how the curves are drawn. It must always be a string containing
        references to LineStyle, Marker and Color specifiers.These references must be set inside the string (order is not
        important) in an unambiguous way. For example, to specify a red
        long-dashed line with the diamond mark enabled, you can write :
        <tt>
          <b>'r--d'</b>
        </tt> or <tt>
          <b>'--dire'</b>
        </tt> or
        <tt>
          <b>'--reddiam'</b>
        </tt> or another unambiguous statement... or to be
        totally complete <tt>
          <b>'diamondred--'</b>
        </tt> (see
        <a href="LineSpec.htm">
          <tt>
            <b>LineSpec</b>
          </tt>
        </a>).<p>Note that the line style and color, marks color (and sizes) can
        also be (re-)set throught the polyline entity properties (see
        <a href="polyline_properties.htm">
            <tt>
              <b>polyline_properties</b>
            </tt>
          </a>).</p>
        <dl>
          <dd>
            <b></b>
          </dd>
        </dl>
        <dl>
          <dd>
            <b></b>
          </dd>
        </dl>
      </dd>
      <dd>
        <b>GlobalProperty</b>: This option may be used to specify how all the curves are
        plotted using more option than via <tt>
          <b>LineSpec</b>
        </tt>. It must
        always be a couple statement constituted of a string defining the
        <tt>
          <b>PropertyName</b>
        </tt>, and its associated value
        <tt>
          <b>PropertyValue</b>
        </tt> (which can be a string or an integer or...
        as well depending on the type of the <tt>
          <b>PropertyName</b>
        </tt>). Using
        <tt>
          <b>GlobalProperty</b>
        </tt>, you can set multiple properties : every
        properties available via LineSpec and more : the marker color
        (foreground and background), the visibility, clipping and thickness of
        the curves. (see <a href="GlobalProperty.htm">
          <tt>
            <b>GlobalProperty</b>
          </tt>
        </a>)<p>Note that all these properties can be (re-)set throught the
        polyline entity properties (see <a href="polyline_properties.htm">
            <tt>
              <b>polyline_properties</b>
            </tt>
          </a>).</p>
      </dd>
    </dl>
    <h3>
      <font color="blue">Remarks</font>
    </h3>
    <dl>
      <p>By default, successive plots are superposed. To clear the previous
    plot, use <tt>
          <b>clf()</b>
        </tt>. To enable <tt>
          <b>auto_clear</b>
        </tt> mode as
    the default mode, edit your default axes doing:</p>
      <p>da=gda();</p>
      <p>da.auto_clear = 'on'</p>
      <p>A default color table is used to color plotted curves if you do not
    specify a color. When drawing multiple lines, the plot command
    automatically cycles through this table. Here are the used colors:</p>
      <div align="center">
        <table border="2">
          <tr align="center">
            <td>
              <tt>
                <b>R</b>
              </tt>
            </td>
            <td>
              <tt>
                <b>G</b>
              </tt>
            </td>
            <td>
              <tt>
                <b>B</b>
              </tt>
            </td>
          </tr>
          <tr align="center">
            <td>0.</td>
            <td>0.</td>
            <td>1.</td>
          </tr>
          <tr align="center">
            <td>0.</td>
            <td>0.5</td>
            <td>0.</td>
          </tr>
          <tr align="center">
            <td>1.</td>
            <td>0.</td>
            <td>0.</td>
          </tr>
          <tr align="center">
            <td>0.</td>
            <td>0.75</td>
            <td>0.75</td>
          </tr>
          <tr align="center">
            <td>0.75</td>
            <td>0.</td>
            <td>0.75</td>
          </tr>
          <tr align="center">
            <td>0.75</td>
            <td>0.75</td>
            <td>0.</td>
          </tr>
          <tr align="center">
            <td>0.25</td>
            <td>0.25</td>
            <td>0.25</td>
          </tr>
        </table>
      </div>
      <p></p>
      <p>Enter the command <tt>
          <b>plot</b>
        </tt> to see a demo.</p>
    </dl>
    <h3>
      <font color="blue">Examples</font>
    </h3>
    <pre>
// x initialisation 
x=[0:0.1:2*%pi]';
//simple plot
plot(sin(x))
clf()
plot(x,sin(x))
//multiple plot
clf()
plot(x,[sin(x) sin(2*x) sin(3*x)])
clf()

// axis on the right 
plot(x,sin(x)) 
a=gca(); // Handle on current axes entity 
a.y_location ="right"; 
clf()

// axis centered at (0,0)
plot(x-4,sin(x),x+2,cos(x))
a=gca(); // Handle on axes entity
a.x_location = "middle"; 
a.y_location = "middle"; 

// Some operations on entities created by plot ...
a=gca();
a.isoview='on'; 
a.children // list the children of the axes : here it is an Compound child composed of 2 entities 
poly1= a.children.children(2); //store polyline handle into poly1 
poly1.foreground = 4; // another way to change the style...
poly1.thickness = 3;  // ...and the tickness of a curve.
poly1.clip_state='off' // clipping control
a.isoview='off'; 

//LineSpec and GlobalProperty examples:
clf();
t=0:%pi/20:2*%pi;
plot(t,sin(t),'ro-.',t,cos(t),'cya+',t,abs(sin(t)),'--mo')
scf(2)
plot([t ;t],[sin(t) ;cos(t)],'xdat',[1:2])
scf(3)
axfig3 = gca();
scf(4) // should remain blank
plot(axfig3,[t ;t],[sin(t) ;cos(t)],'zdat',[1:2],'marker','d','markerfac','green','markeredg','yel')
xdel(winsid())

//Data specification
t=-%pi:0.1:%pi;
size(t)
plot(t) // simply plots y versus t vector size
clf(); // clear figure

plot(t,sin(t)); // plots sin(t) versus t
clf();

t=[1     1     1     1
   2     3     4     5
   3     4     5     6
   4     5     6     7];

plot(t) // plots each t column versus row size
clf();

subplot(221)
plot(t,sin(t)); // plots sin(t) versus t column by column this time
xtitle("sin(t) versus t")
subplot(222)
plot(t,sin(t)')
xtitle("sin(t)'' versus t")
subplot(223)
plot(t',sin(t))
a=gca();
a.data_bounds=[0 -1;7 1]; // to see the vertical line hiddden by the y axis
xtitle("sin(t) versus t''")
subplot(224)
plot(t',sin(t)')
xtitle("sin(t)'' versus t''")

clf();

//Special case 1
//x : vector ([5 6 7 8]) and y : matrix (t)
x=[5 6 7 8]
plot(x,t);
plot(x',t); // idem, x is automatically transposed to match t (here the columns)
clf()

// Only one matching possibility case : how to make 4 identical plots in 4 manners...
// x is 1x4 (vector) and y is 4x5 (non square matrix)
subplot(221);
plot(x,[t [8;9;10;12]]');
subplot(222);
plot(x',[t [8;9;10;12]]');
subplot(223);
plot(x,[t [8;9;10;12]]');
subplot(224);
plot(x',[t [8;9;10;12]]');
clf()


//Special case 2
// Case where only x or y is a square matrix
//x : matrix (t) and y  : vector ([1 2 3 4])
plot(t,[1 2 3 4]) // equivalent to plot(t,[1 1 1 1;2 2 2 2;3 3 3 3;4 4 4 4])
plot(t,[1;2;3;4]) // the same plot
clf();

// t is transposed : notice the priority given to the columns treatment
plot(t',[1 2 3 4]) // equivalent to plot(t',[1 1 1 1;2 2 2 2;3 3 3 3;4 4 4 4]) 
plot(t',[1 2 3 4]') // the same plot 
clf();

// y is a function defined by..
// ..a primitive
plot(1:0.1:10,sin) // equivalent to plot(1:0.1:10,sin(1:0.1:10))
clf();

// ..a macro:
deff('[y]=toto(x)','y=x.*x')
plot(1:10,toto)
 
</pre>
    <h3>
      <font color="blue">See Also</font>
    </h3>
    <p>
      <a href="plot2d.htm">
        <tt>
          <b>plot2d</b>
        </tt>
      </a>,&nbsp;&nbsp;<a href="surf.htm">
        <tt>
          <b>surf</b>
        </tt>
      </a>,&nbsp;&nbsp;<a href="scf.htm">
        <tt>
          <b>scf</b>
        </tt>
      </a>,&nbsp;&nbsp;<a href="clf.htm">
        <tt>
          <b>clf</b>
        </tt>
      </a>,&nbsp;&nbsp;<a href="xdel.htm">
        <tt>
          <b>xdel</b>
        </tt>
      </a>,&nbsp;&nbsp;<a href="delete.htm">
        <tt>
          <b>delete</b>
        </tt>
      </a>,&nbsp;&nbsp;<a href="LineSpec.htm">
        <tt>
          <b>LineSpec</b>
        </tt>
      </a>,&nbsp;&nbsp;<a href="GlobalProperty.htm">
        <tt>
          <b>GlobalProperty</b>
        </tt>
      </a>,&nbsp;&nbsp;</p>
    <h3>
      <font color="blue">Author</font>
    </h3>
    <p>F.Leray</p>
  </body>
</html>
